/*
 * @Author: your name
 * @Date: 2022-04-15 10:35:53
 * @LastEditTime: 2022-04-15 11:19:15
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /yxfan-cli-dev-server/app/service/project.js
 */
// app/service/user.js
const { Service } = require('egg');

class ProjectService extends Service {
    async find(options) {
        const { ctx } = this;
        const doc = await ctx.model.Project.find(options);
        return doc;
    }
    async insert(rowData) {
        const { ctx } = this;
        const doc = await ctx.model.Project.create(rowData);
        return doc;
    }
    async delete(type, options) {
        const { ctx } = this;
        const typeMap = {
            single: 'deleteOne',
            remove: 'remove',
            deleteMany: 'deleteMany'
        };
        const doc = await ctx.model.Project[typeMap[type]](options);
        return doc;
    }
    async update(source, updateDate) {
        const { ctx } = this;
        const td = await ctx.model.Project.findOneAndUpdate(source, updateDate, { new: true });
        return td;
    }
}

module.exports = ProjectService;